<?php require APP_ROOT.'public/top.php';?>
<?php
	$type_id = pg('type_id');
	$group_id = pg('group_id');
	$table_name = M('classify_type')->where(array('type_id' => $type_id))->getField('table_name');
	$where=pg('where')!=''?pg('where'):array();
	$where['member_id']=$member_id;
	if($group_id)$where['group_id']=$group_id;

	$perpage=20;
	$offset=($p-1)*$perpage;//偏移量
	$list=M($table_name)->where($where)->order('date desc')->limit($offset,$perpage)->select();
	//echo M()->_sql();
	$total_num = M($table_name)->where($where)->count();

	//获取这个推广组的具体设置data
    $datao = [];
          foreach($list as $k=>$v){
             
          	$zxcs+=$v['zxcs'];
            $djcs+=$v['djcs'];
            $djl+=$v['djl'];
            $qccb+=$v['qccb'];
            $pjcb+=$v['pjcb'];
            $countprice+=$v['countprice'];
            $jjcgl+=$v['jjcgl'];
            $zhcb+=$v['zhcb'];
            $cll+=$v['cll'];

            $datao[$v['originality_id']] = M('data')->where(['originality_id'=>$v['originality_id']])->select();
            //echo M()->_sql();
          }
          $datao = json_encode($datao);
$djl=round($djl/(count($list)),2).'%';
$qccb=round($qccb/(count($list)),2);
$pjcb=round($pjcb/(count($list)),2);
$jjcgl=round($jjcgl/(count($list)),2).'%';
$zhcb=round($zhcb/(count($list)),2);
$cll=round($cll/(count($list)),2).'%';
?>

<div id="g-body" class="g-bd f-cb" style="background:none">
  <div class="g-mn">
    <div id="g-content" class="g-ct" style="margin-left:0">
      <?php require APP_ROOT.'public/right.php';?>
      <div class="fixed-wrapper js-header-parent">
        <table id="lists-header" class="c-table1 list e-table-sorter" width="100%">
          <tbody>
            
            
          </tbody>
        </table>
      </div>
      <table id="lists" class="c-table1 list e-table-sorter" width="100%">
      	<thead>
        <tr>
              <th width="49"><input id="check-all" type="checkbox" autocomplete="off">
                全选</th>
              <th width="119">创意缩略图</th>
              <th width="179" sorttype="createtime"><span class="e-table-sorter-header e-table-sorter-desc" sorttype="createtime">创意名称</span></th>
              <th width="179" custom_col="group_name">推广组</th>
              <th width="179" custom_col="plan_name">推广计划</th>
              <th custom_col="ad_model" style="display:none;" width="21">广告模式</th>
              <th custom_col="ad_type" style="display:none;" width="71">推广目的</th>
              <th custom_col="creativetype" width="95">广告样式</th>
              <th custom_col="wildcard" style="display:none;" width="4">通配符类型</th>
              <th width="108" custom_col="status">创意状态&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="审核状态包括以下6种状态:<br/>1.审核通过<br/>2.审核未通过<br/>3.待审核<br/>4.修改待审核<br/>5.暂停<br/>6.媒体资源失效<br/>7.倒计时通配符失效"></i></th>
              <th custom_col="views" sorttype="views" width="95"><span class="e-table-sorter-header" sorttype="views">展现次数</span></th>
              <th custom_col="clicks" sorttype="clicks" width="95"><span class="e-table-sorter-header" sorttype="clicks">点击次数</span></th>
              <th custom_col="click_percent" sorttype="click_percent" width="95"><span class="e-table-sorter-header" sorttype="click_percent">点击率</span></th>
              <th custom_col="thousand_views" sorttype="thousand_views" width="95"><span class="e-table-sorter-header" sorttype="thousand_views">千次展现成本</span></th>
              <th custom_col="click_cost" sorttype="click_cost" width="95"><span class="e-table-sorter-header" sorttype="click_cost">平均点击成本</span></th>
              <th custom_col="total_cost" sorttype="total_cost" width="96"><span class="e-table-sorter-header" sorttype="total_cost">总费用</span></th>
              <th custom_col="bid_rate" sorttype="bid_rate" width="96"><span class="e-table-sorter-header" sorttype="bid_rate">竞价成功率</span></th>
              <th custom_col="converts" style="display:none;" sorttype="converts" width="9"><span class="e-table-sorter-header" sorttype="converts">转化数&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="该计划下所有推广组转化数的总和"></i></span></th>
              <th custom_col="convert_rate" style="display:none;" sorttype="convert_rate" width="9"><span class="e-table-sorter-header" sorttype="convert_rate">转化率&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="转化数/点击数"></i></span></th>
              <th custom_col="convert_cost" sorttype="convert_cost" width="96"><span class="e-table-sorter-header" sorttype="convert_cost">转化成本&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="总费用/转化数，由于总费用可能包含该计划下非oCPC推广组的费用，故显示的转化成本可能偏高"></i></span></th>
              <th custom_col="ocpc_down_active" style="display:none;" sorttype="ocpc_down_active" width="9"><span class="e-table-sorter-header" sorttype="ocpc_down_active">激活数&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="该计划下所有推广组激活数的总和"></i></span></th>
              <th custom_col="active_rate" style="display:none;" sorttype="active_rate" width="9"><span class="e-table-sorter-header" sorttype="active_rate">激活率&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="激活数/点击数"></i></span></th>
              <th custom_col="active_cost" style="display:none;" sorttype="active_cost" width="9"><span class="e-table-sorter-header" sorttype="active_cost">激活成本&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="总费用/激活数"></i></span></th>
              <th custom_col="ocpc_down_reg" style="display:none;" sorttype="ocpc_down_reg" width="9"><span class="e-table-sorter-header" sorttype="ocpc_down_reg">注册数&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="该计划下所有推广组注册数的总和"></i></span></th>
              <th custom_col="reg_rate" style="display:none;" sorttype="reg_rate" width="9"><span class="e-table-sorter-header" sorttype="reg_rate">注册率&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="注册数/激活数"></i></span></th>
              <th custom_col="reg_cost" style="display:none;" sorttype="reg_cost" width="9"><span class="e-table-sorter-header" sorttype="reg_cost">注册成本&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="总费用/注册数"></i></span></th>
              <th custom_col="ocpc_down_retention" style="display:none;" sorttype="ocpc_down_retention" width="9"><span class="e-table-sorter-header" sorttype="ocpc_down_retention">次留数&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="该计划下所有推广组次留数的总和"></i></span></th>
              <th custom_col="retention_rate" sorttype="retention_rate" width="96"><span class="e-table-sorter-header" sorttype="retention_rate">次留率&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="当日次留数/前一日的激活数"></i></span></th>
              <th custom_col="retention_cost" style="display:none;" sorttype="retention_cost" width="9"><span class="e-table-sorter-header" sorttype="retention_cost">次留成本&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="前一日的总费用/当日次留数"></i></span></th>
              <th custom_col="ocpc_down_pay" style="display:none;" sorttype="ocpc_down_pay" width="9"><span class="e-table-sorter-header" sorttype="ocpc_down_pay">付费数&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="该计划下所有推广组付费数的总和"></i></span></th>
              <th custom_col="pay_rate" style="display:none;" sorttype="pay_rate" width="9"><span class="e-table-sorter-header" sorttype="pay_rate">付费率&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="付费数/激活数"></i></span></th>
              <th custom_col="pay_cost" style="display:none;" sorttype="pay_cost" width="9"><span class="e-table-sorter-header" sorttype="pay_cost">付费成本&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="总费用/付费数"></i></span></th>
              <th custom_col="ocpc_down_quality" style="display:none;" sorttype="ocpc_down_quality" width="9"><span class="e-table-sorter-header" sorttype="ocpc_down_quality">质量度&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="该计划下所有推广组质量度数的总和"></i></span></th>
              <th custom_col="quality_rate" style="display:none;" sorttype="quality_rate" width="9"><span class="e-table-sorter-header" sorttype="quality_rate">质量度率&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="质量度数/激活数"></i></span></th>
              <th custom_col="quality_cost" style="display:none;" sorttype="quality_cost" width="9"><span class="e-table-sorter-header" sorttype="quality_cost">质量度成本&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="总费用/质量度数"></i></span></th>
              <th custom_col="call_num" style="display:none;" sorttype="call_num" width="6"><span class="e-table-sorter-header" sorttype="call_num">电话拨打量&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="所筛选日期的总电话拨打数"></i></span></th>
              <th custom_col="form_commit_num" style="display:none;" sorttype="form_commit_num" width="6"><span class="e-table-sorter-header" sorttype="form_commit_num">表单提交量&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="所筛选日期的总表单提交数"></i></span></th>
              <th custom_col="advice_num" style="display:none;" sorttype="advice_num" width="6"><span class="e-table-sorter-header" sorttype="advice_num">咨询量&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="所筛选日期的总咨询窗口调起数"></i></span></th>
              <th custom_col="clue_num" style="display:none;" sorttype="clue_num" width="6"><span class="e-table-sorter-header" sorttype="clue_num">线索量&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="所筛选日期的电话拨打数、表单提交数、咨询数的总和"></i></span></th>
              <th custom_col="clue_rate" style="display:none;" sorttype="clue_rate" width="6"><span class="e-table-sorter-header" sorttype="clue_rate">线索率&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="线索量/点击数"></i></span></th>
              <th custom_col="clue_cost" style="display:none;" sorttype="clue_cost" width="6"><span class="e-table-sorter-header" sorttype="clue_cost">线索成本&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="总费用/线索量"></i></span></th>
              <th custom_col="download_num" style="display:none;" sorttype="download_num" width="6"><span class="e-table-sorter-header" sorttype="download_num">网页下载量&nbsp;<i class="f-efonts f-fs14 j-tips" data-tips="所筛选日期的总网页下载量"></i></span></th>
              <th width="79">操作</th>
            </tr>
        </thead>
        <tbody>
        <tr class="total_row">
            <td width="50" class="j-guide-6"></td>
            <td width="120"></td>
            <td width="180">总计</td>
            <td width="180" custom_col="group_name">--</a></td>
            <td width="180" custom_col="plan_name">--</td>
            <td custom_col="ad_model" style="display: none;">RTB</td>
            <td custom_col="ad_type" style="display: none;"> 移动网站推广 </td>
            <td custom_col="creativetype"> -- </td>
            <td custom_col="wildcard" style="display: none;">-</td>
            <td width="99" custom_col="status" class="f-tal" style="padding:0 5px;text-align:center"> -- </td>
            <td custom_col="views" class="f-tar"><?php echo (int)$zxcs;?></td>
            <td custom_col="clicks" class="f-tar"><?php echo (int)$djcs;?></td>
            <td custom_col="click_percent" class="f-tar"><?php echo round($djl,2);?></td>
            <td custom_col="thousand_views" class="f-tar"><?php echo round($qccb,2);?></td>
            <td custom_col="click_cost" class="f-tar"><?php echo $pjcb;?></td>
            <td custom_col="total_cost" class="f-tar"><?php echo $countprice;?></td>
            <td custom_col="bid_rate" class="f-tar"><?php echo $jjcgl;?></td>
            <td custom_col="converts" style="display: none;" class="f-tar"></td>
            <td custom_col="convert_rate" style="display: none;" class="f-tar"></td>
            <td custom_col="convert_cost" class="f-tar"><?php echo $zhcb;?></td>
            <td custom_col="ocpc_down_active" style="display: none;" class="f-tar">--</td>
            <td custom_col="active_rate" style="display: none;" class="f-tar">--</td>
            <td custom_col="active_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="ocpc_down_reg" style="display: none;" class="f-tar">--</td>
            <td custom_col="reg_rate" style="display: none;" class="f-tar">--</td>
            <td custom_col="reg_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="ocpc_down_retention" style="display: none;" class="f-tar">--</td>
            <td custom_col="retention_rate" class="f-tar"><?php echo $cll;?></td>
            <td custom_col="retention_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="ocpc_down_pay" style="display: none;" class="f-tar">--</td>
            <td custom_col="pay_rate" style="display: none;" class="f-tar">--</td>
            <td custom_col="pay_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="ocpc_down_quality" style="display: none;" class="f-tar">--</td>
            <td custom_col="quality_rate" style="display: none;" class="f-tar">--</td>
            <td custom_col="quality_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="call_num" style="display: none;" class="f-tar">0</td>
            <td custom_col="form_commit_num" style="display: none;" class="f-tar">0</td>
            <td custom_col="advice_num" style="display: none;" class="f-tar">0</td>
            <td custom_col="clue_num" style="display: none;" class="f-tar">0</td>
            <td custom_col="clue_rate" style="display: none;" class="f-tar">0</td>
            <td custom_col="clue_cost" style="display: none;" class="f-tar">0</td>
            <td custom_col="download_num" style="display: none;" class="f-tar">0</td>
            <td width="80">--&nbsp;&nbsp;&nbsp; </td>
          </tr>
          
                  <?php
    //print_r($list);
				foreach($list as $k=>$v){
				?>
          <tr>
            <td width="50" class="j-guide-6"><input type="checkbox" name="check-id" data-iscomposevideo="0" data-adspacetypeids="" data-solutionid="650977657" data-adtype="2" data-status="0" data-creativetype="native" data-campaingos="1" data-size="200x150" data-sizeid="887" data-disabled="0" value="6701098308"></td>
            <td width="120"><img class="thumbnail" src="<?php if(strstr($v['originality_img'],'.mp4')!=false) {
                    echo 'images/chuangyi.jpg';
                }else{
                    echo $v['originality_img'];
                }

                ;?>" style="border:solid 1px #e5e5e5;height:30px;vertical-align:middle;width:30px"></td>
            <td width="180"><?php echo $v['originality_name'];?></td>
            <td width="180" custom_col="group_name"><a href="index.php?m=plan&a=index&type_id=64">
              <?php $group=M('group')->where(array('group_id'=>$v['group_id']))->find();
                  echo M('plan')->where(array('plan_id'=>$group['plan_id']))->getfield('plan_name');?></a></td>
            <td width="180" custom_col="plan_name"><a href="index.php?m=group&a=index&type_id=64"><?php echo $group['group_name'];?></a></td>
            <td custom_col="ad_model" style="display: none;">RTB</td>
            <td custom_col="ad_type" style="display: none;"> 移动网站推广 </td>
            <td custom_col="creativetype"> <?php echo M('input')->where(array('input_pid'=>590,'input_value'=>$v['originality_type']))->getfield('input_name');?> </td>
            <td custom_col="wildcard" style="display: none;">-</td>
            <td width="99" custom_col="status" class="f-tal" style="padding:0 5px;text-align:center">
              <?php $state= M('input')->where(array('input_pid'=>647,'input_value'=>$v['state']))->getfield('input_name');?>
			<?php if($v['state']==2){?>
              <span class="g-status-green"><?php echo $state;?></span>
              <?php }else if($v['state']==1){?>
            <span class="g-status-orange"><?php echo $state;?></span>
              <?php }?>
              
            </td>
            <td custom_col="views" class="f-tar originality_zxcs_<?php echo $v['originality_id'];?>" ><?php echo (int)$v['zxcs'];?></td>
            <td custom_col="clicks" class="f-tar originality_djcs_<?php echo $v['originality_id'];?>"><?php echo (int)$v['djcs'];?></td>
            
            <td custom_col="click_percent" class="f-tar"><?php echo round($v['djl'],2);?></td>
            <td custom_col="thousand_views" class="f-tar"><?php echo round($v['qccb'],2);?></td>
            <td custom_col="click_cost" class="f-tar"><?php echo $v['pjcb'];?></td>
            <td custom_col="total_cost" class="f-tar originality_countprice_<?php echo $v['originality_id'];?>"><?php echo $v['countprice'];?></td>
            <td custom_col="bid_rate" class="f-tar originality_jjcgl_<?php echo $v['originality_id'];?>">
                
                
                   
                <?php $data = M('data')->where("originality_id = ".$v['originality_id']." and end_date > $time")->count();

                //echo M()->_sql();
                        if($data==0){
                            echo $v['jjcgl'];
                        }
                ?>

            </td>
<!--            <td custom_col="bid_rate" class="f-tar originality_jjcgl_--><?php //echo $v['originality_id'];?><!--">--><?php //echo $v['jjcgl'];?><!--</td>-->
            <td custom_col="converts" style="display: none;" class="f-tar"></td>
            <td custom_col="convert_rate" style="display: none;" class="f-tar"></td>
            <td custom_col="convert_cost" class="f-tar"> <?php if($data==0){
                    echo $v['zhcb'];
                }else{
                echo 0;
                }
            ?></td>
            <td custom_col="ocpc_down_active" style="display: none;" class="f-tar">--</td>
            <td custom_col="active_rate" style="display: none;" class="f-tar">--</td>
            <td custom_col="active_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="ocpc_down_reg" style="display: none;" class="f-tar">--</td>
            <td custom_col="reg_rate" style="display: none;" class="f-tar">--</td>
            <td custom_col="reg_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="ocpc_down_retention" style="display: none;" class="f-tar">--</td>
            <td custom_col="retention_rate" class="f-tar"><?php  if($data==0){
                   echo $v['cll'];
                }else{
                    echo 0;
                } ?></td>
            <td custom_col="retention_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="ocpc_down_pay" style="display: none;" class="f-tar">--</td>
            <td custom_col="pay_rate" style="display: none;" class="f-tar">--</td>
            <td custom_col="pay_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="ocpc_down_quality" style="display: none;" class="f-tar">--</td>
            <td custom_col="quality_rate" style="display: none;" class="f-tar">--</td>
            <td custom_col="quality_cost" style="display: none;" class="f-tar">--</td>
            <td custom_col="call_num" style="display: none;" class="f-tar">0</td>
            <td custom_col="form_commit_num" style="display: none;" class="f-tar">0</td>
            <td custom_col="advice_num" style="display: none;" class="f-tar">0</td>
            <td custom_col="clue_num" style="display: none;" class="f-tar">0</td>
            <td custom_col="clue_rate" style="display: none;" class="f-tar">0</td>
            <td custom_col="clue_cost" style="display: none;" class="f-tar">0</td>
            <td custom_col="download_num" style="display: none;" class="f-tar">0</td>
            <td width="80"><a href="index.php?m=originality&a=edit&type_id=<?php echo $type_id;?>&table_name=<?php echo $table_name;?>&content_id=<?php echo $v[$table_name.'_id'];?>" title="编辑创意"><i class="f-efonts f-fs18 f-blue f-vam"></i></a>&nbsp;&nbsp;&nbsp; <a onclick="if(confirm('确定删除吗!')){ajax_list('index.php?m=cms&a=del_save&type_id=65&content_id=<?php echo $v['originality_id'];?>','')}" class="btn-del" data-disabled="2" data-id="6701098308" data-name="15986605234_200x150" href="javascript:void(0)" title="删除创意"><i class="f-efonts f-fs16 f-blue"></i></a></td>
          </tr>
          
          <?php }?>
          
          
          
          
        </tbody>
      </table>
      <?php require APP_ROOT.'public/page.php';?>
    </div>
  </div>
</div>

<?php require APP_ROOT.'public/bottom.php';?>
